<template>
    <div>
        <p>用户名：<input type="text" v-model="name"></p>
        <p>密码：<input type="text" v-model="password"></p>
        <p><Button @click="login">登录</button></p>

    </div>
</template>

<script>
export default {
    data () {
        return {
            name:'',
            password:''
            
        }
    },
    methods: {
        login(){
            this.axios.get('http://127.0.0.1:8000/mylearn/coslogin/',{params:{'name':this.name,'password':this.password}})
            .then(result=>{
                 console.log(result)
                if(result.data.code==200){
                    localStorage.setItem('name',result.data.name)
                    localStorage.setItem('id',result.data.id)
                    this.$Message(result.data.msg)
                    this.$router.push('cosshow')
                   
                }
                else{
                     this.$Message(result.data.msg)
                }

            })
        },
      
    },

}
</script>

<style>

</style>
